/**
 * @file: ioctl.c
 * @brief: 中间层，包含调度顶层和底层的函数和数据结构
 * @author: liaowx
 * @date: 2019.07.30
 */

#include <stdio.h>
#include <malloc.h>

#include "app.h"
#include "ioctl.h"
#include "device.h"

struct core *sort_ioctl(int cmd, struct core *sort_core)
{
    struct core *ret_sort_core;
    switch (cmd) {
        case DEV_CTL:
            sort_core->dev_ctl(sort_core->arg);
            break;
        case GET_DEV_CTL:
            ret_sort_core = get_dev();
            return ret_sort_core;
        default:
            break;
    }

    return NULL;
}

int match(struct core *app_core, struct core *sort_core)
{
    int num = 0;

    for (; num < SORT_NUM; num++) {
        if (app_core->cmd == sort_core[num].cmd) {
            sort_core[num].arg = app_core->arg;

            return app_core->cmd;
        }
    }

    return FALSE;
}